package com.taotao.job.rpc.sofabolt;

import com.alipay.remoting.rpc.RpcServer;
import com.taotao.job.rpc.server.AbstractRpcProviderServer;
import com.taotao.job.rpc.server.hold.ProviderHolder;
import com.taotao.job.rpc.server.invoker.LocalInvoker;
import lombok.extern.slf4j.Slf4j;


/**
 * @author fanbeibei
 * @date 2021/4/4 9:29
 */
@Slf4j
public class SofaboltProviderServer extends AbstractRpcProviderServer {
    /**
     * port
     */
    private int port;
    /**
     * rpc server
     */
    private RpcServer server;


    public SofaboltProviderServer(int port) {
        this.port = port;
    }

    @Override
    public void start() {
        server = new RpcServer(port, true, false);
        LocalInvoker invokerLocal = new LocalInvoker(providerHolder);
        server.registerUserProcessor(new RequestDataAsyncUserProcessor(invokerLocal));
        server.startup();
    }

    @Override
    public void stop() {
        server.shutdown();
    }


}
